package com.laputacastle.dr.minio;

import io.minio.MinioClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author liwb
 */
@Component
public class MinioConnect {
	protected final Logger logger = LoggerFactory.getLogger(MinioConnect.class);

	private MinioClient minioClient;

	@Autowired
	public MinioConnect(@Value("${minio.httpurl}") String httpurl,
						@Value("${minio.akey}") String akey,
						@Value("${minio.skey}") String skey){
		try {
			minioClient = new MinioClient(httpurl, akey, skey, false);
			logger.info("minio连接成功");
		} catch (Exception e) {
			logger.error("minio连接失败", e);
		}
	}
	
	public MinioClient getClient() {
		return minioClient;
	}
}
